import 'package:yurun_smartmerchants/models/approach_save_request_entity.dart';
import 'package:yurun_smartmerchants/models/tallyallotrequest_entity.dart';
import 'NetUtil.dart';

class ApiInterface {
  //获取经营类型
  static final String CMD_BusinessType =
      'ep-wmms-archives/businessType/getBusinessType';

  //获取短信验证码
  static final String cmd_verify_code =
      'ep-wmms-archives/account/get/verification/code';

  //登录
  static final String cmd_login = 'auth/login/by/verify/code';

  //保存个人备案信息
  static final String cmd_save = 'ep-wmms-archives/account/save';

  ///图片上传接口
  static final String cmd_uploadImage = 'ep-wmms-system/file/upload/app/public';

  //主页获取consumerId等相关信息
  static final String cmd_home_consumer_type =
      'ep-wmms-archives/consumer/get/record/type';

  //获取车辆类型
  static final String cmd_vehicle_types = 'ep-wmms-ois/vehicle/app/types';

  //新增或者修改车辆
  static final String cmd_add_car = 'ep-wmms-ois/vehicle/smart/app/save';

  //查询车辆
  static final String cmd_query_car = 'ep-wmms-ois/vehicle/smart/app/list';

  //删除车辆
  static final String cmd_delete_car = 'ep-wmms-ois/vehicle/smart/app/delete';

  //车辆详情
  static final String cmd_detail_car = 'ep-wmms-ois/vehicle/app/info';

//进场保存
  static final String cmd_save_car = 'ep-wmms-ois/enter/area/smart/save';

  //进场列表
  static final String cmd_car_list = 'ep-wmms-ois/enter/area/smart/page';

  //版本更新
  static final String cmd_update_app = 'ep-wmms-system/app/version';

  //商品分类
  static final String cmd_goods_classification =
      'ep-wmms-ois/productCategory/smart/by/lev';

  //客户列表
  static final String cmd_custom_list = 'ep-wmms-archives/customer/list';

  //客户新增
  static final String cmd_custom_save = 'ep-wmms-archives/customer/save';

  //客户删除
  static final String cmd_custom_delete = 'ep-wmms-archives/customer/delete';

  //主页获取身份码
  static final String cmd_qrcode = 'ep-wmms-archives/consumer/get/id/card';

  //上传的头像和账号绑定
  static final String cmd_account_upload_img =
      'ep-wmms-archives/account/upload/img';

  //主页扫码
  static final String cmd_qrcode_scan =
      'ep-wmms-archives/consumer/validate/jwt';
  ///个人备案详情
  static final String cmd_get_info = 'ep-wmms-archives/account/get/info';

  //企业备案
  static final String cmd_entterprise_save = 'ep-wmms-archives/consumer/save';

  //获取企业备案信息
  static final String cmd_get_entterprise_information =
      'ep-wmms-archives/consumer/get';

  //理货列表
  static final String cmd_tally_list = 'ep-wmms-product/tally/list';

  ///员工列表
  static final String cmd_staff_list = 'ep-wmms-archives/employee/list';

  ///新增员工
  static final String cmd_add_staff = 'ep-wmms-archives/employee/add';
  
  ///理货详情、重新理货
  static final String cmd_tallyDetail = 'ep-wmms-product/product/findByCateId';

  ///确认理货
  static final String cmd_tally_allot = 'ep-wmms-product/tally/allot';

  ///修改员工
  static final String cmd_staff_modify = 'ep-wmms-archives/employee/modify';

  ///删除员工
  static final String cmd_staff_delete = 'ep-wmms-archives/employee/del';

  ///库存管理品类
  static final String cmd_category_good = 'ep-wmms-product/customized/category/list4product';

  ///品类对应的商品列表
  static final String cmd_good_list = 'ep-wmms-product/product/list';

  ///库存批次
  static final String cmd_inventory_batch_list = 'ep-wmms-product/stock/product/list';

  ///库存明细
  static final String cmd_inventory_detail_list = 'ep-wmms-product/stock/product/detail/list';

  ///报损
  static final String cmd_damaged= 'ep-wmms-product/wastage/submit';

  static Future getVerifyCode(
    String phoneNum,
  ) async {
    return NetUtil.postJson(cmd_verify_code, {"phone": phoneNum});
  }

  static Future getBusinessType() async {
    return NetUtil.postJson(CMD_BusinessType, {});
  }

  static Future getVehicleTypes() async {
    return NetUtil.postJson(cmd_vehicle_types, {});
  }

  static Future addCar(int id, String provinceShortName, String licencePlate,
      double tare, int vehicleTypeId, List<int> listId) async {
    return NetUtil.postJson(cmd_add_car, {
      "id": id,
      "licencePlate": licencePlate,
      "provinceShortName": provinceShortName,
      "tare": tare,
      "vehicleTypeId": vehicleTypeId,
      "consumerId": listId
    });
  }

  static Future queryCar(int consumerId) async {
    return NetUtil.postJson(cmd_query_car, {"consumerId": consumerId});
  }

  static Future deleteCar(int consumerId, int carId) async {
    return NetUtil.postJson(
        cmd_delete_car, {"id": carId, "consumerId": consumerId});
  }

  static Future detailCar(int carId) async {
    return NetUtil.postJson(cmd_detail_car, {"id": carId});
  }

  static Future personInformationSave(Map<String, dynamic> parameter) async {
    return NetUtil.postJson(cmd_save, parameter);
  }

  static Future login(String phoneNum, String verifyCode) async {
    return NetUtil.postJson(
        cmd_login, {"phone": phoneNum, "verifyCode": verifyCode});
  }

  static Future uploadPublicImage(
      String file, String ext, String fileName) async {
    return NetUtil.postJson(
        cmd_uploadImage, {"files": file, "ext": ext, "fileName": fileName});
  }

  static Future homeConsumerType() async {
    return NetUtil.postJson(cmd_home_consumer_type, {});
  }

  static Future getQRCode() async {
    return NetUtil.postJson(cmd_qrcode, {
      'param': {'type': 1}
    });
  }

  static Future scanCode(String scanResult) async {
    return NetUtil.postJson(cmd_qrcode_scan, {'name': scanResult});
  }

  static Future getGoodsClassification() async {
    return NetUtil.postJson(cmd_goods_classification, {});
  }

  static Future getAccountUploadImg(String url) async {
    return NetUtil.postJson(cmd_account_upload_img, {"url": url});
  }

  static Future saveCar(ApproachSaveEntity approachSaveEntity) async {
    return NetUtil.postJson(cmd_save_car, approachSaveEntity.toJson());
  }

  static Future getCarList(int size, int page, int tidyStatus) async {
    return NetUtil.postJson(
        cmd_car_list, {"size": size, "page": page, "tidyStatus": tidyStatus});
  }

  static Future updateApp() async {
    return NetUtil.postJson(cmd_update_app, {});
  }

  static Future getPersonInfo(int type) async {
    return NetUtil.postJson(cmd_get_info, {'type': type});
  }

  static Future getCustomList(int pageSize, int pageNum) async {
    return NetUtil.postJson(
        cmd_custom_list, {"pageSize": pageSize, "pageNum": pageNum});
  }

  static Future getCustomAdd(String name, String phone) async {
    return NetUtil.postJson(cmd_custom_save, {"name": name, "phone": phone});
  }

  static Future getCustomdelete(int id) async {
    return NetUtil.postJson(cmd_custom_delete, {"id": id});
  }

  static Future saveEnterpriseInformation(
      Map<String, dynamic> parameter) async {
    return NetUtil.postJson(cmd_entterprise_save, parameter);
  }

  static Future getEnterpriseInformation(int id) async {
    return NetUtil.postJson(cmd_entterprise_save, {'id': id});
  }

  static Future tallyList(Map<String, dynamic> parameter) async {
    return NetUtil.postJson(cmd_tally_list, parameter);
  }

  static Future getStaffList(int page, int size) async {
    return NetUtil.postJson(
        cmd_staff_list, {'pageNum': page, 'pageSize': size});
  }

  static Future addStaff(code, phone, name) async {
    return NetUtil.postJson(
        cmd_add_staff, {"verifyCode": code, "phone": phone, "name": name});
  }
  
  static Future tallyDetail(int id, int status, int categoryiiiId) {
    return NetUtil.postJson(cmd_tallyDetail, {'id':id,'status':status,'categoryiiiId':categoryiiiId});
  }

  static Future modifyStaff(id,name) {
    return NetUtil.postJson(cmd_staff_modify, {'id':id,'name':name,});
  }


  static Future confirmTally(TallyallotrequestEntity entity) {
  return NetUtil.postentityJson(cmd_tally_allot, entity);
  }

  static Future deleteStaff(id) {
    return NetUtil.postJson(cmd_staff_delete, {'id':id});
  }

  static Future getCategoryGood() {
    return NetUtil.postJson(cmd_category_good, {});
  }

  static Future getGoodsList(id,page,size) {
    return NetUtil.postJson(cmd_good_list, {'customizedCategoryId':id,'pageNum': page, 'pageSize': size});
  }

  static Future getInventoryBatch(id,page,size) {
    return NetUtil.postJson(cmd_inventory_batch_list, {'id':id,'pageNum': page, 'pageSize': size});
  }

  static Future getInventoryDetail(id,page,size) {
    return NetUtil.postJson(cmd_inventory_detail_list, {'id':id,'pageNum': page, 'pageSize': size});
  }

  static Future damaged(id,quantity) {
    return NetUtil.postJson(cmd_damaged, {'id':id,'quantity': quantity});
  }

}
